//
//  SPBluetoothManager.h
//  Spinning
//
//  Created by Neil on 2018/1/25.
//  Copyright © 2018年 com. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <BabyBluetooth.h>
 
@protocol SPBluetoothDelegate;
@interface SPBluetoothManager : NSObject

@property (nonatomic, copy) NSString *rpmString;
@property (nonatomic, copy) NSString *pulseString;
@property (nonatomic, copy) NSString *speedString;
@property (nonatomic, assign) NSTimeInterval connectedTime;
@property (nonatomic, copy) NSString *connectPeripheralName;
@property (nonatomic, strong) CBPeripheral *fitNowPeripheral;

@property (nonatomic, weak) id <SPBluetoothDelegate> delegate;

@property (nonatomic, assign, getter=isConnected) BOOL connected;
@property (nonatomic, assign, getter=isBluetoothOpen) BOOL bluetoothOpen;
@property (nonatomic, strong) NSMutableString *mStr;

@property (nonatomic, assign) BOOL isRecharge;// 是否是充值
@property (nonatomic, assign) BOOL isRechargeConfirm;// 是否是确认充值，是则不用处理数据



// 0:物联网燃气表 1:IC无线卡
@property (nonatomic, assign) NSInteger deviceType1;


@property (nonatomic, strong) NSMutableString *dataMStr;
@property (nonatomic, strong) NSMutableString *dataMStrRecharge;

// 卡攻击次数
@property (nonatomic, strong) NSString *CardAttTimes;

// 累计量
@property (nonatomic, strong) NSString *Cumulant;

// 当月累计量
@property (nonatomic, strong) NSString *CurrMonthTotal;

// 上月累计量
@property (nonatomic, strong) NSString *Last1MonthTotal;

// 磁攻击次数
@property (nonatomic, strong) NSString *MagAttTimes;

// 表状态
@property (nonatomic, strong) NSString *MeterState;

// 过流次数
@property (nonatomic, strong) NSString *OverFlowTimes;

// 过零金额
@property (nonatomic, strong) NSString *OverZeroMoney;

// 剩余金额
@property (nonatomic, strong) NSString *SurplusMoney;

// 当前单价
@property (nonatomic, strong) NSString *accPrice;

// 报警金额
@property (nonatomic, strong) NSString *alarmMoney;

// 设备类型
@property (nonatomic, strong) NSString *deviceType;

// 第一阶梯量
@property (nonatomic, strong) NSString *endAmount1;

// 第二阶梯量
@property (nonatomic, strong) NSString *endAmount2;

// 第三阶梯量
@property (nonatomic, strong) NSString *endAmount3;

// 定时价格
@property (nonatomic, strong) NSString *fixedPrice;

// 价格类型标志
@property (nonatomic, strong) NSString *fluidType;

// 周期间隔时间（月）
@property (nonatomic, strong) NSString *intervalMonth;

// 可透支金额
@property (nonatomic, strong) NSString *maxOverMoney;

// 过流量
@property (nonatomic, strong) NSString *maxOverdraft;

// 阶梯价1
@property (nonatomic, strong) NSString *price1;

// 阶梯价2
@property (nonatomic, strong) NSString *price2;

// 阶梯价3
@property (nonatomic, strong) NSString *price3;

// 周期开始时间
@property (nonatomic, strong) NSString *startTime;

// 累计充值金额
@property (nonatomic, strong) NSString *sumRechargeMoney;

// 累计用气金额
@property (nonatomic, strong) NSString *sumUseMoney;

// 分时时间1
@property (nonatomic, strong) NSString *timeArea1;

// 分时时间2
@property (nonatomic, strong) NSString *timeArea2;

// 分时时间3
@property (nonatomic, strong) NSString *timeArea3;

// 分时价格1
@property (nonatomic, strong) NSString *timePrice1;

// 分时价格2
@property (nonatomic, strong) NSString *timePrice2;

// 分时价格3
@property (nonatomic, strong) NSString *timePrice3;

// 本周期使用量
@property (nonatomic, strong) NSString *weekUseVolume;

// 卡区域id
@property (nonatomic, strong) NSString *cardRegionNo;

// 卡id
@property (nonatomic, strong) NSString *cardID;

// 气表编号
@property (nonatomic, strong) NSString *cardNo;

// 价格版本号
@property (nonatomic, strong) NSString *VersionNumber;



+ (instancetype)shareManager;

// 充值写卡
- (void)writeCard:(NSString *)str;

//- (void)startConnect;
- (void)disconnect;
- (void)startScan;
- (void)connectToPeripheral:(CBPeripheral *)peripheral;

@end

@protocol SPBluetoothDelegate <NSObject>

@optional

- (void)bluetoothStateOpen;
- (void)bluetoothUpdateriji:(NSString *)riji;

- (void)bluetoothDiscoveredPeripheral:(CBPeripheral *)peripheral;
- (void)bluetoothConnected:(CBPeripheral *)peripheral;
//- (void)bluetoothUpdateRpm:(NSString *)rpm pulse:(NSString *)pulse speed:(NSString *)speed dataString:(NSString *)dataString;
- (void)bluetoothSendData;
- (void)bluetoothDisconnected;

@end
